
//19496
import { safeCb } from './safeCb'
import { keys } from './keys'
/**
 * 类似 map，但针对对象，生成一个新对象
 * mapObj({ a: 1, b: 2 }, function(val, key) {
    return val + 1;
   }); // -> {a: 2, b: 3}
   dependencies safeCb keys types
 * @param {*} object 源对象
 * @param {*} iterator 转换函数
 * @param {*} context 函数上下文
 * @returns 
 */
export function mapObj (obj, iterator, ctx) {
  iterator = safeCb(iterator, ctx);

  var _keys = keys(obj);

  var len = _keys.length;
  var ret = {};

  for (var i = 0; i < len; i++) {
    var curKey = _keys[i];
    ret[curKey] = iterator(obj[curKey], curKey, obj);
  }

  return ret;
}